from pathlib import Path
p = Path('ixc-qa/')
l = p.glob('deepseek*.md')

# file manip
# --------------------------------------------------
# 1. rename these by replacing : in name with -:
for f in l:
    new_name = f.name.replace(':', '-')
    new_path = f.parent / new_name
    f.rename(new_path)
    print(f"Renamed {f} to {new_path}")

# --------------------------------------------------
# 2. merge db folder

p = Path('../ixc-qa/')            # main
p0 = Path('../ixc-qa0/')            # sub
import json
# 2.1 load two indexes
i = json.loads((p / 'index.json').read_text())
i0 = json.loads((p0 / 'index.json').read_text())

for x in i0:
    if x not in i:
        print(f'🦜 : appending {x}')
        i.append(x)
# save
print(f'saving {i} to index')
# (p / 'index.json').write_text(json.dumps(i))
# 2.2 copy the files
l = p0.glob('*.md')
for f in l:
    f0 = p / f.name
    print(f'🦜 : renaming {f} -> {f0}')

# 2.3 rm the sub folder
